package com.csdn.eval.spring.mqtt.demo;

import com.csdn.eval.spring.mqtt.EnableEvalMqtt;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.core.env.Environment;

import java.net.InetAddress;

/**
 * 文件迁移服务启动类
 */
@Slf4j
@SpringBootApplication
@EnableEvalMqtt
public class MqttDemoApplication {

    public static String applicationIp;

    public static void main(String[] args) throws Exception {
        SpringApplication app = new SpringApplicationBuilder(MqttDemoApplication.class).web(WebApplicationType.SERVLET)
                .build();
        Environment env = app.run(args).getEnvironment();
        String protocol = "http";
        if (env.getProperty("server.ssl.key-store") != null) {
            protocol = "https";
        }
        log.info(
                "\n---------------------------------------------------------------------------------------\n\t"
                        + "Application '{}' is running! Access URLs:\n\t"
                        + "Local: \t\t{}://localhost:{}/swagger-ui.html\n\t"
                        + "External: \t{}://{}:{}/swagger-ui.html\n\t"
                        + "Profile(s): \t{}"
                        + "\n---------------------------------------------------------------------------------------",
                env.getProperty("spring.application.name"),
                protocol,
                env.getProperty("server.port"),
                protocol,
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"),
                env.getActiveProfiles());
    }
}